<template>
  <div class="banxin">
    <Breabcrumb>
      <span slot="name1">{{ nav[0].name }}</span>
      <span slot="name2">{{ nav[1].name }}</span>
    </Breabcrumb>
    <div class="details">
      <div class="leftbox">
        <div class="left_item">
          <img :src="'https://sc.wolfcode.cn' + productInfo.coverImg" class="imgitem" width="100%" height="100%" alt="" />
          <ul class="simg">
            <!-- 存放图片的盒子绑定事件，把图片路径传送到事件中 -->
            <li @mouseenter="setBigImg(item.src)" v-for="(item, index) in productInfo.imgAltas" :key="index"><img width="100%" height="100%" :src="'https://sc.wolfcode.cn' + item.src" alt="" /></li>
          </ul>
        </div>
        <div class="right_item">
          <div class="right_itemtop">
            <h1>{{productInfo.seriesTitle}}</h1>
            <p>{{productInfo.seriesSubTitle}}</p>
            <div class="rightji">{{productInfo.coin}}积分</div>
          </div>
          <div class="right_itembottom">
            <section v-for="(item, index) in productInfo.parameterJson" :key="index">
              <div class="xuanze">选择{{ item.title }}</div>
              <ul class="selitem">
                <li :class="items.currentActivate ? 'active' : ''" v-for="items in item.parameters" :key="items.id" @click="$router.push(`/details?id=${items.id}`)">{{ items.title }}</li>
              </ul>
            </section>
            <div style="margin-bottom: 14px">
              数量 <span>礼品库存{{ productInfo.stock }}件</span>
            </div>
            <div class="setnum">
              <span class="sub" @click="Sreduce">-</span>
              <span class="center">{{ sNum }}</span>
              <span class="jia" @click="addnum">+</span>
            </div>
            <div class="btns">
              <button @click="addToCartFn">加入购物车</button>
              <button>立即兑换</button>
            </div>
            <div class="loveshare">
              <div class="love">
                <img src="../assets/images/details/like-click.png" alt="" />
                <span>喜欢 2</span>
              </div>
              <div class="share">
                <vshare :vshareConfig="vshareConfig"></vshare>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="rightbox">
        <h1>你还可以兑换</h1>
        <ul>
          <li @click="$router.push(`/details?id=${item.id}`)" class="otherget" v-for="item in themYouCanBuy" :key="item.id">
            <div class="othergetleft"><img :src="'https://sc.wolfcode.cn' + item.img" alt="" /></div>
            <div class="othergetright">
              <p class="boxtext">{{ item.name }}</p>
              <span class="score">{{ item.coin }}</span>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <ul class="setTab">
      <li class="gift" :class="flag===true?'activemsg':''" @click="flag = true">
        礼品详情
      </li>
      <li class="comqsn" :class="flag===false?'activemsg':''" @click="flag = false">
        常见问题
      </li>
    </ul>
    <div class="messagemodel">
      <div v-show="flag" v-html="productInfo.description" class="message1"></div>
      <div v-show="!flag" class="message2">
        <strong style="font-size:18px"> 兑换后运费如何收取？</strong>

      <p>商城内大部分实物产品均可包邮，也支持上门自提。虚拟产品则无需运费，可在兑换后直接使用。
（注：新疆，西藏，内蒙古，青海，海南，宁夏暂不支持包邮，在此地区兑换商品需提前与客服确认运费。）</p>

 

 

 <strong> 如何申请退换货？</strong>

<p>所有产品均为鸡腿兑换礼品，无质量问题不支持退换货；
如因喜好不同，或到货后后悔等原因，不支持退货；
因客户原因如联系方式有误、电话停机、不接电话、无理由拒收等造成快件无法正常签收的情况，叩丁狼均不进行补发或赔付；
如因质量问题需要退货，将由客服人员与客户联系，确认邮寄地址与流程。退回物品不得有人为损坏或使用痕迹，否则拒绝退换；
如顾客选择自行寄回商品，请先垫付运费，到货验证商品后，叩丁狼将以鸡腿发放形式为用户报销运费，不接受单方面到付件。
 </p>

<strong> 如何开具发票？</strong>

<p>叩丁狼积分商城产品均为定制礼品，使用积分兑换的产品均不支持开票。</p>

 

<strong> 关于鸡腿价格问题</strong>

<p>因可能存在系统缓存、页面更新延迟等不确定性情况，导致价格显示异常，商品具体售价请以订单结算页价格为准。如您发现异常情况出现，请立即联系我们补正，以便您能顺兑换。</p>

 

联系我们

www.wolfcode.cn

微信公众号搜索“叩丁狼”
      </div>
    </div>
  </div>
</template>

<script>  
import vshare from 'vshare'
import { GoodsDetailApi,AddToCartApi } from '../request/api.js'
import Breabcrumb from '../components/home/Breabcrumb.vue'
export default {
  methods: {
    addToCartFn(){
      AddToCartApi({
        productId:this.$route.query.id,
        total:this.sNum,
        modified:1
      }).then(res=>{
        if(res.code === 0){
          //单击加入购物车添加成功后触发自定义事件
          this.$emit('fn')
          this.$store.dispatch('changeToastAsync',{
              msg:'加入成功',
             type:'success'
      })
        }else{
          this.$store.dispatch('changeToastAsync',{
              msg:'加入失败',
             type:'danger'
      })
        }
      })
    },
    //接受路径，更改父组件绑定变量的路径
    setBigImg(src) {
      this.productInfo.coverImg = src
    },
    Sreduce() {
      if (this.sNum === 0) {
        return
      }
      this.sNum--
    },
    addnum() {
      {
        {
          this.sNum === this.productInfo.stock
        }
      }
      this.sNum++
    },
  },
  data() {
    return {
      flag:true,
      sNum: 1,
      nav: [
        {
          name: '',
        },
        {
          name: '',
        },
      ],
      productInfo: {
        parameterJson: [
          {
            parameters: [],
          },
        ],
      },
      themYouCanBuy: [],
      // 分享功能的配置
      vshareConfig: {
        // 此处放分享列表（ID）
        shareList: ['weixin', 'qzone'],
        //此处放置分享按钮设置
        share: [{ bdSize: 24 }],
        //此处放置浮窗分享设置
        slide: false,
      },
    }
  },
  components: {
    Breabcrumb,
    vshare,
  },
  created() {
    GoodsDetailApi({
      //url中的id值
      id: this.$route.query.id,
    }).then((res) => {
      if (res.code === 0) {
        console.log(res)
        let { nav, productInfo, themYouCanBuy } = res.data
        this.nav = nav
        this.productInfo = productInfo
        this.productInfo.description = productInfo.description.replace(/upload/g, 'http://sc.wolfcode.cn/upload');
        this.themYouCanBuy = themYouCanBuy
      }
    })
  },
  watch: {
    '$route.query.id': {
      handler(newVal, oldVal) {
        if (newVal != oldVal) this.$router.go(0)
      },
    },
  },
}
</script>

<style lang="less" scoped>
@import url('../totao.css');
.details {
  border-bottom: 1px solid #ececec;
  padding-bottom: 48px;
  box-sizing: border-box;
  // padding-top: 57px;
  display: flex;
  .leftbox {
    width: 965px;
    padding-top: 18px;
    display: flex;
    justify-content: space-between;
    .left_item {
      width: 460px;
      .imgitem {
        width: 457px;
        height: 457px;
      }
      .simg {
        width: 457px;
        display: flex;
        justify-content: space-between;
        padding-top: 18px;
        li {
          width: 100px;
          height: 100px;
          background-color: green;
          cursor: pointer;
          //亮度为一半
          filter: brightness(50%);
          &:hover {
            // 鼠标经过亮度为一百
            filter: brightness(100%);
          }
        }
      }
    }
    .right_item {
      padding-left: 32px;
      width: 455px;
      .right_itemtop {
        border-bottom: 1px solid #ececec;
        h1 {
          font-size: 28px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #000000;
          margin: 7px 0;
        }
        p {
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;

          letter-spacing: 0px;
          color: #999999;
        }
        .rightji {
          font-size: 28px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #fd604d;
          margin: 23px 0;
        }
      }
      .right_itembottom {
        padding-top: 20px;
        .xuanze {
          margin-bottom: 14px;
        }
        .selitem {
          display: flex;
          flex-wrap: wrap;
          li {
            min-width: 50px;
            cursor: pointer;
            padding-left: 4px;
            padding-right: 4px;
            height: 44px;
            border: solid 1px #d1d1d1;
            color: #666666;
            text-align: center;
            line-height: 44px;
            margin-right: 20px;
            margin-bottom: 11px;
          }
          .active {
            border: solid 1px#0a328e;
            color: #0a328e;
          }
        }
        .setnum {
          display: flex;
          text-align: center;
          line-height: 34px;
          user-select: none;
          .sub {
            cursor: pointer;
            width: 30px;
            height: 34px;
            border: solid 1px #d1d1d1;
          }
          .center {
            width: 46px;
            height: 34px;
            border: solid 1px #d1d1d1;
            border-left: 0;
            border-right: 0;
          }
          .jia {
            cursor: pointer;
            width: 30px;
            height: 34px;
            border: solid 1px #d1d1d1;
          }
        }
        .btns {
          padding: 24px 0;
          button {
            width: 150px;
            height: 46px;
            margin-right: 19px;
            text-align: center;
            line-height: 46px;
            font-size: 18px;
            font-weight: normal;
            font-stretch: normal;
            border: 0;
            color: #ffffff;
            cursor: pointer;
            background: #3dc36b;
            &:nth-child(2) {
              background: #fd604d;
            }
          }
        }
        .loveshare {
          display: flex;
          .love {
            border-right: 1px solid #ececec;
            display: flex;
            align-items: center;
            span {
              padding-left: 12px;
              padding-right: 17px;
            }
          }
          .share {
            padding-left: 17px;
          }
        }
      }
    }
  }
  .rightbox {
    width: 235px;
    padding-left: 20px;
    border-left: 1px solid #ececec;
    margin-left: 50px;
    h1 {
      margin-bottom: 20px;
    }
    ul {
      .otherget {
        cursor: pointer;
        margin-bottom: 30px;
        display: flex;
        .othergetleft {
          width: 78px;
          height: 88px;
          
          img {
            width: 100%;
            border: 1px solid transparent;
          }  
        }
        
        .othergetright {
          display: flex;
          flex-direction: column;
          justify-content: space-around;
          padding-left: 10px;
          width: 140px;
          .boxtext {
            //超出一行边省略号
            text-overflow: ellipsis;
            width: 100%;
            overflow: hidden;
            white-space: nowrap;
            font-size: 14px;
            font-weight: bold;
            color: #666666;
          }
          .score {
            font-weight: bold;
            color: #666666;
            color: #ff5e0f;
          }
          
        }
        &:hover{
          img{
            border: 1px solid #333999;
          }
          .boxtext{
            color: #0a328e;
          }
        }
      }
    }
  }
}
.banxin {
  .setTab{
    width: 100%;
    background: #fff;
    display: flex;
    .activemsg{
          color: #333;
    background-color: #ececec;
    }
  li{
    width: 120px;
    height: 50px;
    background-color: #fff;
    font-size: 18px;
    font-weight: normal;
    font-stretch: normal;
    line-height: 50px;
    letter-spacing: 0px;
    color: #999999;
    cursor: pointer;
    text-align: center;
  }
  }
  .messagemodel{
    padding-top: 27px;
    .message2{
      strong{
        font-size: 18px;
        font-weight: bold;
      }
      p{
        padding-bottom: 19px;
      }
    }
  }
}
</style>
